package cn.xiazhi.charging.device.controller;


import cn.xiazhi.charging.pojo.param.GunStatusUpdateParam;
import cn.xiazhi.charging.device.service.DeviceService;
import cn.xiazhi.charging.common.JsonResult ;
import cn.xiazhi.charging.pojo.param.StationInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/device")
@Api(tags = "设备接口")
public class DeviceController {


    @Autowired
    private DeviceService deviceService;


    @ApiOperation("获取场站信息")
    @GetMapping("/station/info/{gunId}")
    public JsonResult<StationInfoVO> getUserInfo(@PathVariable("gunId") Integer gunId){
        log.debug("获取场站信息:{}",gunId);
        StationInfoVO stationInfoVO = deviceService.getStationInfo(gunId);
        JsonResult ok = JsonResult.ok(stationInfoVO);
        log.debug("获取场站信息:{},结果:{}",gunId,ok);
        return ok;
    }

    @ApiOperation("更新枪状态")
    @PostMapping("/station/gun/status/update")
    public JsonResult<Boolean> updateGunStatus(@RequestBody GunStatusUpdateParam param) {
        log.debug("更新枪状态:{}",param);
        Boolean success = deviceService.updateGunStatus(param);
        JsonResult ok = JsonResult.ok(success);
        log.debug("更新枪状态:{},结果:{}",param,ok);
        return ok;
    }
}